#include <stdio.h>
#include <sys/stat.h> 
#include <fcntl.h>

int main(void){
	printf("Open /dev/cdata \r\n");
	int fd = -1;
	int write_size = 0;

	pid_t child,self;

	const char input_bytes[20]="HELO";

	child = fork();
	fd = open("/dev/cdata", O_RDWR);
	printf("fd = %d\r\n",fd);
	
	if( child !=0 ){
		self = getpid();
		printf("Parent process, PID = %d\r\n", self);
		printf("Child process ID: %d\n", (int) child);
	}else{
		printf("This is the child process: %d\r\n", (int) getpid());
	}

	write_size = write(fd,input_bytes,5);
	close(fd);

	return 0;
}
